{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# (Introduction to Tensorflow) * 10^6"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this notebook, we modify the [tensor-fied intro to TensorFlow notebook](https://github.com/the-deep-learners/TensorFlow-LiveLessons/blob/master/notebooks/tensor-fied_intro_to_tensorflow.ipynb) to use placeholder tensors and feed in data from a data set of millions of points. This is a derivation of Jared Ostmeyer's [Naked Tensor](https://github.com/jostmey/NakedTensor/) code. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "np.random.seed(42)\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "import tensorflow as tf\n",
    "tf.set_random_seed(42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "xs = np.linspace(0., 8., 8000000) # eight million points spaced evenly over the interval zero to eight\n",
    "ys = 0.3*xs-0.8+np.random.normal(scale=0.25, size=len(xs)) # eight million labels given xs, m=0.3, b=-0.8, plus normally-distributed noise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXuQVPd157+ne+5AN4rVQ0Ri0WIEUVxgE8KMxUrYVKWC\n7AjJWGisByNFyiapZLXZsreC7JrNkGglpCilSc1KsNlkkxDbG3ulxciAxsiQRfFCygkJkgYNCCFB\noifQEGtsaBQxjeiZOftH921u376/e3/30e/zqaKYx+17f9MD5/x+5/E9xMwQBEEQ2o9YvRcgCIIg\n1AdxAIIgCG2KOABBEIQ2RRyAIAhCmyIOQBAEoU0RByAIgtC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ZmXs/M1zDzfBT+be1l5qrtzvxARLOKiXxT\nf+tmFAY21RVm/lcAJ4loYfFLnwNQ9yIDC/eiQcI/RU4AWE5EyeL/z8+hkJurCi01FJ6ZJ4noKwD2\nAIgD+CYzH63zsgAARLQFwC8DuKqon/QIM3+jvqvCCgC/BuBIMdYOAL/PzLtdXlMrrgbwrWKFRgzA\ns8zcUGWXDcbPAniuOJypA8D/aSDNrf8M4JnipuxtAL9Z5/UAAIgoiULF4H+s91pMmPlFItoG4BUA\nkwDGUMWu4JYqAxUEQRD0abUQkCAIgqCJOABBEIQ2RRyAIAhCmyIOQBAEoU0RByAIgtCmiAMQBEFo\nU8QBCIIgtCniAARBENqU/w9fxU24OHlM0wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fe794e43e10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots()\n",
    "data_subset = pd.DataFrame(list(zip(xs, ys)), columns=['x', 'y']).sample(n=1000)\n",
    "_ = ax.scatter(data_subset.x, data_subset.y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "m = tf.Variable(-0.5)\n",
    "b = tf.Variable(1.0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "batch_size = 8 # sample mini-batches of size eight for each step of gradient descent"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Define *placeholder tensors* of length *batch_size* whose values will be filled in during graph execution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "xs_placeholder = tf.placeholder(tf.float32, [batch_size])\n",
    "ys_placeholder = tf.placeholder(tf.float32, [batch_size])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Define graph that incorporates placeholders"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ys_model = m*xs_placeholder+b\n",
    "total_error = tf.reduce_sum((ys_placeholder-ys_model)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "optimizer_operation = tf.train.GradientDescentOptimizer(learning_rate=0.001).minimize(total_error) # demo 0.01, 0.0001"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "initializer_operation = tf.global_variables_initializer()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Sample from the full data set while running the session"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "with tf.Session() as session:\n",
    "    \n",
    "    session.run(initializer_operation)\n",
    "    \n",
    "    n_batches = 1000 # 10, then 1000\n",
    "    for iteration in range(n_batches):\n",
    "        random_indices = np.random.randint(len(xs), size=batch_size) # sample the batch by random selection\n",
    "        feed = { # feeds are dictionaries\n",
    "            xs_placeholder: xs[random_indices],\n",
    "            ys_placeholder: ys[random_indices]\n",
    "        }\n",
    "        session.run(optimizer_operation, feed_dict=feed) # minimize cost with the mini-batch\n",
    "    \n",
    "    slope, intercept = session.run([m, b])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.30601835"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "slope"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.77169347"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "intercept"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
